<?php
/**
 *
 * @author maomao.thx@gmail.com
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: Design.php 929 2011-10-27 07:52:50Z mmxie $
 */
class IG_Report_Design
{
    /**
     *
     * @var IG_Report_Design_Abstract
     */
    private static $instance;

    /**
     *
     * @param string $adapter
     * @param array $options
     */
    public static function factory($adapter, $options)
    {
        if (self::$instance == null) {
            $className = 'IG_Report_Design_' . ucfirst($adapter);
            if(class_exists($className) && (self::$instance = new $className($options)) instanceof IG_Report_Design_Abstract) {
                return self::$instance;
            } else {
                throw new Exception('Class \'' . $className . '\' is not exists or not instance of IG_Report_Design_Abstract');
            }
        }
        return self::$instance;
    }
}